package fabriques;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Connexion {
	public static Connexion con;
	
	private static Connection laConnexion;

	public static synchronized Connexion getInstance(){
		if(con == null)
			con = new Connexion();
		return con;
	}
	
	private Connexion(){
		try {
			//Class.forName("org.hsqldb.jdbcDriver");
	    	Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		try {
			//laConnexion = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/carbdd;shutdown=true", "sa", "");
			laConnexion = DriverManager.getConnection("jdbc:mysql://localhost:1234/ProjetCAR","root","root");
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public static Connection getCon(){
		return laConnexion;
	}
	
	public static void closeConnexion(){
		try {
			laConnexion.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
}
